#!/bin/bash

set -o errexit
set -o xtrace

jobs=1
export DERIVED_SOURCES_DIR="$1"
export SRCROOT="$PWD/.."

mkdir -p "${DERIVED_SOURCES_DIR}/WebKit2"
cd "${DERIVED_SOURCES_DIR}/WebKit2"

make --no-builtin-rules -f "$SRCROOT/DerivedSources.make" -j $jobs WebKit2="$SRCROOT"
make --no-builtin-rules -f "$SRCROOT/DerivedSources-manx.make" -j $jobs WebKit2="$SRCROOT"
"$SRCROOT/Scripts/generate-forwarding-headers.pl" "$SRCROOT" "${DERIVED_SOURCES_DIR}/WebKit2/include" CoordinatedGraphics
"$SRCROOT/Scripts/generate-forwarding-headers.pl" "$SRCROOT" "${DERIVED_SOURCES_DIR}/WebKit2/include" cairo
"$SRCROOT/Scripts/generate-forwarding-headers.pl" "$SRCROOT" "${DERIVED_SOURCES_DIR}/WebKit2/include" manx
"$SRCROOT/Scripts/generate-forwarding-headers-coreipc.pl" "${SRCROOT}/manx/CoreIPC" "${DERIVED_SOURCES_DIR}/CoreIPC/include" manx
